<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="{:url('sales/cost/examine')}">

<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Number')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-number" data-rule="required" class="form-control" name="row[number]" type="text">-->
<!--        </div>-->
<!--    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">单据类型:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="number_type" id="" class="form-control" disabled>
                <option value="1"  {if condition="$row.source_type == 2"} selected {else /} {/if}>入库单</option>
                <option value="2"  {if condition="$row.source_type == 7"} selected {else /} {/if}>出库单</option>
                <option value="2"  {if condition="$row.source_type == 12"} selected {else /} {/if}>厂家直发</option>
            </select>
        </div>
    </div>
    <div class="form-group number_obj"  {if condition="$row.source_type == 12"}  {else /}style="display: none" {/if}>
        <label class="control-label col-xs-12 col-sm-2">单据对象:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="" data-rule="required"   name="number_obj" type="radio" value="1" {if condition="$row.number_obj == 1"} checked {else /} {/if}>客户
            <input id="" data-rule="required"   name="number_obj" type="radio" value="2" {if condition="$row.number_obj == 2"} checked {else /} {/if}>供应商
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">单据编号:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-sale_number" data-rule="required" class="form-control" name="source_number" type="text" value="{$row.source_number}" disabled>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">费用类型:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="type" id="" class="form-control" disabled>
                {volist name="types" id="vo"}
                <option value="{$key}"{if condition="$row.type == $key"} selected {else /} {/if} >{$vo}</option>
                {/volist}
            </select>
<!--            <input id="c-type" data-rule="required" class="form-control" name="row[type]" type="number">-->
        </div>
    </div>
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Sales_checkout_id')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-sales_checkout_id" data-rule="required" data-source="sales/checkout/index" class="form-control selectpage" name="row[sales_checkout_id]" type="text" value="">-->
<!--        </div>-->
<!--    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">金额:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-cost" data-rule="required" class="form-control" step="0.01" name="cost" type="text" onkeyup="checkTaxFloat(this);" value="{$row.cost}" disabled>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">是否支出:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="" data-rule="required"   name="is_income" type="radio" value="1" {if condition="$row.is_income == 1"} checked {else /} {/if} disabled>收入
            <input id="" data-rule="required"   name="is_income" type="radio" value="2" {if condition="$row.is_income == 2"} checked {else /} {/if} disabled>支出
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea rows="3" cols="20" class="form-control" name="remark" disabled>{$row.remark}</textarea>
<!--            <input id="c-remark" data-rule="required" class="form-control" name="row[remark]" type="text" value="">-->
        </div>
    </div>
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Group_id')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-group_id" data-rule="required" data-source="group/index" class="form-control selectpage" name="row[group_id]" type="text" value="">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Operator')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-operator" class="form-control" name="row[operator]" type="text">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Company')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-company" class="form-control" name="row[company]" type="text">-->
<!--        </div>-->
<!--    </div>-->
    <input type="hidden" value="{$row.id}" name="ids">
    {if condition="$auth->check('sales/cost/examine') && $row.status == 1 "}
    <input type="hidden" name="status" value="1">
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed subpurchase">{:__('OK')}</button>
            <button type="submit" class="btn btn-default btn-embossed reset">驳回</button>
        </div>
    </div>
    {else /}

    {/if}
</form>

<input type="hidden" name="status" value="1">
<div class="form-group layer-footer">
    <label class="control-label col-xs-3 col-sm-2"></label>
    <div class="col-xs-12 col-sm-3">
        <button type="submit" class="btn btn-error btn-embossed joint-search" data-name="{$name}" data-con="{$controller}" data-id="{$row.source_id}">{:__('单据联查')}</button>
    </div>
    {if condition="$row.status == 2"}
    <label class="control-label col-xs-3 col-sm-2"></label>
    <div class="col-xs-12 col-sm-3">
        <button type="submit" class="btn btn-danger btn-embossed cancelbill {:$auth->check('sales/cost/cancelbill')?'':'hide'}">{:__('单据红冲')}</button>
    </div>
    {else /}
    {/if}
</div>




<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script>
    function checkTaxFloat(obj) {
        obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数
        var x = obj.value.indexOf('.') + 1;   //小数点的位置
        var y = obj.value.length;

        if(x>1 && (y-x) >0){
            if((y-x)>1){
                obj.value= parseFloat(obj.value).toFixed(1)
            }
        }
        if(obj.value.indexOf(".")< 0 && obj.value !=""){
            obj.value= parseFloat(obj.value)
        }
    }

    $('.subpurchase').click(function () {
        $("input[name='status']").val(2)
    })
    $('.reset').click(function () {
        $("input[name='status']").val(3)
    })

</script>
